package com.liuyanzhao.ssm.blog.service.impl;

import com.liuyanzhao.ssm.blog.entity.App;
import com.liuyanzhao.ssm.blog.mapper.AppMapper;
import com.liuyanzhao.ssm.blog.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (App)表服务实现类
 *
 * @author lsl
 * @since 2021-08-16 11:20:54
 */
@Service
public class AppServiceImpl implements AppService {
    @Autowired
    private AppMapper appDao;

    /**
     * 通过ID查询单条数据
     *
     * @param appId 主键
     * @return 实例对象
     */
    @Override
    public App queryById(Integer appId) {
        return this.appDao.queryById(appId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<App> queryAllByLimit(int offset, int limit) {
        return this.appDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param app 实例对象
     * @return 实例对象
     */
    @Override
    public App insert(App app) {
        this.appDao.insert(app);
        return app;
    }

    /**
     * 修改数据
     *
     * @param app 实例对象
     * @return 实例对象
     */
    @Override
    public void update(App app) {
        this.appDao.update(app);
    }

    /**
     * 通过主键删除数据
     *
     * @param appId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer appId) {
        return this.appDao.deleteById(appId) > 0;
    }

    @Override
    public List<App> listApp(String appName) {

        return this.appDao.listApp(appName);
    }
}
